home *** CD-ROM | disk | FTP | other *** search
/ Erotic Games: Memory / Erotic Games: Memory.iso / mac / air_installers / AdobeAIR.exe / setup.swf / scripts / components / LocalizedButton.as < prev    next >
Text File  |  2009-02-12  |  5KB  |  176 lines

  1. package components
  2. {
  3.    import flash.text.Font;
  4.    import mx.controls.Button;
  5.    import mx.events.PropertyChangeEvent;
  6.    import mx.styles.StyleManager;
  7.    
  8.    public class LocalizedButton extends Button
  9.    {
  10.       
  11.       private static var fontArray:Array = Font.enumerateFonts(false);
  12.        
  13.       
  14.       private var isFontRetrieved:Boolean = false;
  15.       
  16.       private var defaultAppFontFamily:String;
  17.       
  18.       private var _resourceName:String;
  19.       
  20.       private var _resourceParams:Array;
  21.       
  22.       private var _bundleName:String;
  23.       
  24.       private var _useHTML:Boolean = false;
  25.       
  26.       private var cachedEmbeddedFont:Font;
  27.       
  28.       public function LocalizedButton()
  29.       {
  30.          super();
  31.       }
  32.       
  33.       private function set _143661260resourceParams(param1:Array) : void
  34.       {
  35.          trace(this.id + " set resourceName: " + this.resourceName);
  36.          this._resourceParams = param1;
  37.          invalidateProperties();
  38.       }
  39.       
  40.       [Bindable(event="propertyChange")]
  41.       public function set resourceName(param1:String) : void
  42.       {
  43.          var _loc2_:Object = this.resourceName;
  44.          if(_loc2_ !== param1)
  45.          {
  46.             this._384566343resourceName = param1;
  47.             this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"resourceName",_loc2_,param1));
  48.          }
  49.       }
  50.       
  51.       override protected function commitProperties() : void
  52.       {
  53.          if(this.resourceName)
  54.          {
  55.             label = this.localizeText();
  56.          }
  57.          super.commitProperties();
  58.       }
  59.       
  60.       private function set _384566343resourceName(param1:String) : void
  61.       {
  62.          this._resourceName = param1;
  63.          invalidateProperties();
  64.       }
  65.       
  66.       private function set _1377046061bundleName(param1:String) : void
  67.       {
  68.          this._bundleName = param1;
  69.          invalidateProperties();
  70.       }
  71.       
  72.       protected function localizeText() : String
  73.       {
  74.          return LocalizationManager.getInstance().getString(this.resourceName,this.bundleName,this.resourceParams);
  75.       }
  76.       
  77.       override public function initialize() : void
  78.       {
  79.          super.initialize();
  80.       }
  81.       
  82.       [Bindable(event="propertyChange")]
  83.       public function set bundleName(param1:String) : void
  84.       {
  85.          var _loc2_:Object = this.bundleName;
  86.          if(_loc2_ !== param1)
  87.          {
  88.             this._1377046061bundleName = param1;
  89.             this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"bundleName",_loc2_,param1));
  90.          }
  91.       }
  92.       
  93.       [Bindable(event="propertyChange")]
  94.       public function set useHTML(param1:Boolean) : void
  95.       {
  96.          var _loc2_:Object = this.useHTML;
  97.          if(_loc2_ !== param1)
  98.          {
  99.             this._148395598useHTML = param1;
  100.             this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"useHTML",_loc2_,param1));
  101.          }
  102.       }
  103.       
  104.       protected function ensureGlyphs(param1:String) : void
  105.       {
  106.          var _loc2_:String = null;
  107.          var _loc3_:Font = null;
  108.          if(!this.isFontRetrieved)
  109.          {
  110.             this.isFontRetrieved = true;
  111.             _loc2_ = getStyle("fontFamily");
  112.             if(_loc2_.match(/,/))
  113.             {
  114.                return;
  115.             }
  116.             for each(_loc3_ in fontArray)
  117.             {
  118.                if(_loc3_.fontName == _loc2_)
  119.                {
  120.                   this.cachedEmbeddedFont = _loc3_;
  121.                   this.defaultAppFontFamily = StyleManager.getStyleDeclaration("Application").getStyle("fontFamily");
  122.                }
  123.             }
  124.          }
  125.          if(this.cachedEmbeddedFont)
  126.          {
  127.             if(!this.cachedEmbeddedFont.hasGlyphs(param1))
  128.             {
  129.                setStyle("fontFamily",this.defaultAppFontFamily);
  130.             }
  131.             else
  132.             {
  133.                setStyle("fontFamily",this.cachedEmbeddedFont.fontName);
  134.             }
  135.          }
  136.       }
  137.       
  138.       [Bindable(event="propertyChange")]
  139.       public function set resourceParams(param1:Array) : void
  140.       {
  141.          var _loc2_:Object = this.resourceParams;
  142.          if(_loc2_ !== param1)
  143.          {
  144.             this._143661260resourceParams = param1;
  145.             this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"resourceParams",_loc2_,param1));
  146.          }
  147.       }
  148.       
  149.       private function set _148395598useHTML(param1:Boolean) : void
  150.       {
  151.          this._useHTML = param1;
  152.          invalidateProperties();
  153.       }
  154.       
  155.       public function get useHTML() : Boolean
  156.       {
  157.          return this._useHTML;
  158.       }
  159.       
  160.       public function get resourceParams() : Array
  161.       {
  162.          return this._resourceParams;
  163.       }
  164.       
  165.       public function get resourceName() : String
  166.       {
  167.          return this._resourceName;
  168.       }
  169.       
  170.       public function get bundleName() : String
  171.       {
  172.          return this._bundleName;
  173.       }
  174.    }
  175. }
  176.